set(SRCS_ZLIB
        ${LIBRARY_DIR}/Foundation/src/adler32.c
        ${LIBRARY_DIR}/Foundation/src/compress.c
        ${LIBRARY_DIR}/Foundation/src/crc32.c
        ${LIBRARY_DIR}/Foundation/src/deflate.c
        ${LIBRARY_DIR}/Foundation/src/infback.c
        ${LIBRARY_DIR}/Foundation/src/inffast.c
        ${LIBRARY_DIR}/Foundation/src/inflate.c
        ${LIBRARY_DIR}/Foundation/src/inftrees.c
        ${LIBRARY_DIR}/Foundation/src/trees.c
        ${LIBRARY_DIR}/Foundation/src/zutil.c
    )
add_library(_poco_foundation_zlib ${SRCS_ZLIB})
add_library(Poco::Foundation::ZLIB ALIAS _poco_foundation_zlib)

set(SRCS_PCRE
        ${LIBRARY_DIR}/Foundation/src/pcre2_auto_possess.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_chartables.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_chkdint.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_compile.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_config.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_context.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_convert.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_dfa_match.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_error.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_extuni.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_find_bracket.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_jit_compile.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_maketables.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_match.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_match_data.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_newline.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_ord2utf.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_pattern_info.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_script_run.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_serialize.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_string_utils.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_study.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_substitute.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_substring.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_tables.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_ucd.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_valid_utf.c
        ${LIBRARY_DIR}/Foundation/src/pcre2_xclass.c
        )

add_library(_poco_foundation_pcre ${SRCS_PCRE})
add_library(Poco::Foundation::PCRE ALIAS _poco_foundation_pcre)

target_compile_options(_poco_foundation_pcre PRIVATE -Wno-sign-compare)

set(SRCS_UTF8PROC
        ${LIBRARY_DIR}/Foundation/src/utf8proc.c
)

add_library(_poco_foundation_utf8proc ${SRCS_UTF8PROC})
add_library(Poco::Foundation::UTF8PROC ALIAS _poco_foundation_utf8proc)

# Foundation

set(SRCS
        ${LIBRARY_DIR}/Foundation/src/ASCIIEncoding.cpp
        ${LIBRARY_DIR}/Foundation/src/AbstractObserver.cpp
        ${LIBRARY_DIR}/Foundation/src/ActiveDispatcher.cpp
        ${LIBRARY_DIR}/Foundation/src/ActiveThreadPool.cpp
        ${LIBRARY_DIR}/Foundation/src/ArchiveStrategy.cpp
        ${LIBRARY_DIR}/Foundation/src/Ascii.cpp
        ${LIBRARY_DIR}/Foundation/src/AsyncChannel.cpp
        ${LIBRARY_DIR}/Foundation/src/AsyncNotificationCenter.cpp
        ${LIBRARY_DIR}/Foundation/src/AtomicCounter.cpp
        ${LIBRARY_DIR}/Foundation/src/AtomicFlag.cpp
        ${LIBRARY_DIR}/Foundation/src/Base32Decoder.cpp
        ${LIBRARY_DIR}/Foundation/src/Base32Encoder.cpp
        ${LIBRARY_DIR}/Foundation/src/Base64Decoder.cpp
        ${LIBRARY_DIR}/Foundation/src/Base64Encoder.cpp
        ${LIBRARY_DIR}/Foundation/src/BinaryReader.cpp
        ${LIBRARY_DIR}/Foundation/src/BinaryWriter.cpp
        ${LIBRARY_DIR}/Foundation/src/BufferedBidirectionalStreamBuf.cpp
        ${LIBRARY_DIR}/Foundation/src/BufferedStreamBuf.cpp
        ${LIBRARY_DIR}/Foundation/src/Bugcheck.cpp
        ${LIBRARY_DIR}/Foundation/src/ByteOrder.cpp
        ${LIBRARY_DIR}/Foundation/src/Channel.cpp
        ${LIBRARY_DIR}/Foundation/src/Checksum.cpp
        ${LIBRARY_DIR}/Foundation/src/Clock.cpp
        ${LIBRARY_DIR}/Foundation/src/Condition.cpp
        ${LIBRARY_DIR}/Foundation/src/Configurable.cpp
        ${LIBRARY_DIR}/Foundation/src/ConsoleChannel.cpp
        ${LIBRARY_DIR}/Foundation/src/CountingStream.cpp
        ${LIBRARY_DIR}/Foundation/src/DataURIStream.cpp
        ${LIBRARY_DIR}/Foundation/src/DataURIStreamFactory.cpp
        ${LIBRARY_DIR}/Foundation/src/DateTime.cpp
        ${LIBRARY_DIR}/Foundation/src/DateTimeFormat.cpp
        ${LIBRARY_DIR}/Foundation/src/DateTimeFormatter.cpp
        ${LIBRARY_DIR}/Foundation/src/DateTimeParser.cpp
        ${LIBRARY_DIR}/Foundation/src/Debugger.cpp
        ${LIBRARY_DIR}/Foundation/src/DeflatingStream.cpp
        ${LIBRARY_DIR}/Foundation/src/DigestEngine.cpp
        ${LIBRARY_DIR}/Foundation/src/DigestStream.cpp
        ${LIBRARY_DIR}/Foundation/src/DirectoryIterator.cpp
        ${LIBRARY_DIR}/Foundation/src/DirectoryIteratorStrategy.cpp
        ${LIBRARY_DIR}/Foundation/src/DirectoryWatcher.cpp
        ${LIBRARY_DIR}/Foundation/src/Environment.cpp
        ${LIBRARY_DIR}/Foundation/src/Error.cpp
        ${LIBRARY_DIR}/Foundation/src/ErrorHandler.cpp
        ${LIBRARY_DIR}/Foundation/src/Event.cpp
        ${LIBRARY_DIR}/Foundation/src/EventArgs.cpp
        ${LIBRARY_DIR}/Foundation/src/EventChannel.cpp
        ${LIBRARY_DIR}/Foundation/src/Exception.cpp
        ${LIBRARY_DIR}/Foundation/src/FIFOBufferStream.cpp
        ${LIBRARY_DIR}/Foundation/src/FPEnvironment.cpp
        ${LIBRARY_DIR}/Foundation/src/File.cpp
        ${LIBRARY_DIR}/Foundation/src/FileChannel.cpp
        ${LIBRARY_DIR}/Foundation/src/FileStream.cpp
        ${LIBRARY_DIR}/Foundation/src/FileStreamFactory.cpp
        ${LIBRARY_DIR}/Foundation/src/FileStreamRWLock.cpp
        ${LIBRARY_DIR}/Foundation/src/Format.cpp
        ${LIBRARY_DIR}/Foundation/src/Formatter.cpp
        ${LIBRARY_DIR}/Foundation/src/FormattingChannel.cpp
        ${LIBRARY_DIR}/Foundation/src/Glob.cpp
        ${LIBRARY_DIR}/Foundation/src/Hash.cpp
        ${LIBRARY_DIR}/Foundation/src/HashStatistic.cpp
        ${LIBRARY_DIR}/Foundation/src/HexBinaryDecoder.cpp
        ${LIBRARY_DIR}/Foundation/src/HexBinaryEncoder.cpp
        ${LIBRARY_DIR}/Foundation/src/InflatingStream.cpp
        ${LIBRARY_DIR}/Foundation/src/JSONFormatter.cpp
        ${LIBRARY_DIR}/Foundation/src/JSONString.cpp
        ${LIBRARY_DIR}/Foundation/src/Latin1Encoding.cpp
        ${LIBRARY_DIR}/Foundation/src/Latin2Encoding.cpp
        ${LIBRARY_DIR}/Foundation/src/Latin9Encoding.cpp
        ${LIBRARY_DIR}/Foundation/src/LineEndingConverter.cpp
        ${LIBRARY_DIR}/Foundation/src/LocalDateTime.cpp
        ${LIBRARY_DIR}/Foundation/src/LogFile.cpp
        ${LIBRARY_DIR}/Foundation/src/LogStream.cpp
        ${LIBRARY_DIR}/Foundation/src/Logger.cpp
        ${LIBRARY_DIR}/Foundation/src/LoggingFactory.cpp
        ${LIBRARY_DIR}/Foundation/src/LoggingRegistry.cpp
        ${LIBRARY_DIR}/Foundation/src/MD4Engine.cpp
        ${LIBRARY_DIR}/Foundation/src/MD5Engine.cpp
        ${LIBRARY_DIR}/Foundation/src/Manifest.cpp
        ${LIBRARY_DIR}/Foundation/src/MemoryPool.cpp
        ${LIBRARY_DIR}/Foundation/src/MemoryStream.cpp
        ${LIBRARY_DIR}/Foundation/src/Message.cpp
        ${LIBRARY_DIR}/Foundation/src/Mutex.cpp
        ${LIBRARY_DIR}/Foundation/src/NamedEvent.cpp
        ${LIBRARY_DIR}/Foundation/src/NamedMutex.cpp
        ${LIBRARY_DIR}/Foundation/src/NestedDiagnosticContext.cpp
        ${LIBRARY_DIR}/Foundation/src/Notification.cpp
        ${LIBRARY_DIR}/Foundation/src/NotificationCenter.cpp
        ${LIBRARY_DIR}/Foundation/src/NotificationQueue.cpp
        ${LIBRARY_DIR}/Foundation/src/NullChannel.cpp
        ${LIBRARY_DIR}/Foundation/src/NullStream.cpp
        ${LIBRARY_DIR}/Foundation/src/NumberFormatter.cpp
        ${LIBRARY_DIR}/Foundation/src/NumberParser.cpp
        ${LIBRARY_DIR}/Foundation/src/NumericString.cpp
        ${LIBRARY_DIR}/Foundation/src/PIDFile.cpp
        ${LIBRARY_DIR}/Foundation/src/Path.cpp
        ${LIBRARY_DIR}/Foundation/src/PatternFormatter.cpp
        ${LIBRARY_DIR}/Foundation/src/Pipe.cpp
        ${LIBRARY_DIR}/Foundation/src/PipeImpl.cpp
        ${LIBRARY_DIR}/Foundation/src/PipeStream.cpp
        ${LIBRARY_DIR}/Foundation/src/PriorityNotificationQueue.cpp
        ${LIBRARY_DIR}/Foundation/src/Process.cpp
        ${LIBRARY_DIR}/Foundation/src/ProcessRunner.cpp
        ${LIBRARY_DIR}/Foundation/src/PurgeStrategy.cpp
        ${LIBRARY_DIR}/Foundation/src/RWLock.cpp
        ${LIBRARY_DIR}/Foundation/src/Random.cpp
        ${LIBRARY_DIR}/Foundation/src/RandomStream.cpp
        ${LIBRARY_DIR}/Foundation/src/RefCountedObject.cpp
        ${LIBRARY_DIR}/Foundation/src/RegularExpression.cpp
        ${LIBRARY_DIR}/Foundation/src/RotateStrategy.cpp
        ${LIBRARY_DIR}/Foundation/src/Runnable.cpp
        ${LIBRARY_DIR}/Foundation/src/SHA1Engine.cpp
        ${LIBRARY_DIR}/Foundation/src/SHA2Engine.cpp
        ${LIBRARY_DIR}/Foundation/src/Semaphore.cpp
        ${LIBRARY_DIR}/Foundation/src/SharedLibrary.cpp
        ${LIBRARY_DIR}/Foundation/src/SharedMemory.cpp
        ${LIBRARY_DIR}/Foundation/src/SignalHandler.cpp
        ${LIBRARY_DIR}/Foundation/src/SimpleFileChannel.cpp
        ${LIBRARY_DIR}/Foundation/src/SortedDirectoryIterator.cpp
        ${LIBRARY_DIR}/Foundation/src/SplitterChannel.cpp
        ${LIBRARY_DIR}/Foundation/src/Stopwatch.cpp
        ${LIBRARY_DIR}/Foundation/src/StreamChannel.cpp
        ${LIBRARY_DIR}/Foundation/src/StreamConverter.cpp
        ${LIBRARY_DIR}/Foundation/src/StreamCopier.cpp
        ${LIBRARY_DIR}/Foundation/src/StreamTokenizer.cpp
        ${LIBRARY_DIR}/Foundation/src/String.cpp
        ${LIBRARY_DIR}/Foundation/src/StringTokenizer.cpp
        ${LIBRARY_DIR}/Foundation/src/SynchronizedObject.cpp
        ${LIBRARY_DIR}/Foundation/src/SyslogChannel.cpp
        ${LIBRARY_DIR}/Foundation/src/Task.cpp
        ${LIBRARY_DIR}/Foundation/src/TaskManager.cpp
        ${LIBRARY_DIR}/Foundation/src/TaskNotification.cpp
        ${LIBRARY_DIR}/Foundation/src/TeeStream.cpp
        ${LIBRARY_DIR}/Foundation/src/TemporaryFile.cpp
        ${LIBRARY_DIR}/Foundation/src/TextBufferIterator.cpp
        ${LIBRARY_DIR}/Foundation/src/TextConverter.cpp
        ${LIBRARY_DIR}/Foundation/src/TextEncoding.cpp
        ${LIBRARY_DIR}/Foundation/src/TextIterator.cpp
        ${LIBRARY_DIR}/Foundation/src/Thread.cpp
        ${LIBRARY_DIR}/Foundation/src/ThreadLocal.cpp
        ${LIBRARY_DIR}/Foundation/src/ThreadPool.cpp
        ${LIBRARY_DIR}/Foundation/src/ThreadTarget.cpp
        ${LIBRARY_DIR}/Foundation/src/TimedNotificationQueue.cpp
        ${LIBRARY_DIR}/Foundation/src/Timer.cpp
        ${LIBRARY_DIR}/Foundation/src/Timespan.cpp
        ${LIBRARY_DIR}/Foundation/src/Timestamp.cpp
        ${LIBRARY_DIR}/Foundation/src/Timezone.cpp
        ${LIBRARY_DIR}/Foundation/src/Token.cpp
        ${LIBRARY_DIR}/Foundation/src/URI.cpp
        ${LIBRARY_DIR}/Foundation/src/URIStreamFactory.cpp
        ${LIBRARY_DIR}/Foundation/src/URIStreamOpener.cpp
        ${LIBRARY_DIR}/Foundation/src/UTF16Encoding.cpp
        ${LIBRARY_DIR}/Foundation/src/UTF32Encoding.cpp
        ${LIBRARY_DIR}/Foundation/src/UTF8Encoding.cpp
        ${LIBRARY_DIR}/Foundation/src/UTF8String.cpp
        ${LIBRARY_DIR}/Foundation/src/UUID.cpp
        ${LIBRARY_DIR}/Foundation/src/UUIDGenerator.cpp
        ${LIBRARY_DIR}/Foundation/src/UnbufferedStreamBuf.cpp
        ${LIBRARY_DIR}/Foundation/src/Unicode.cpp
        ${LIBRARY_DIR}/Foundation/src/UnicodeConverter.cpp
        ${LIBRARY_DIR}/Foundation/src/Var.cpp
        ${LIBRARY_DIR}/Foundation/src/VarHolder.cpp
        ${LIBRARY_DIR}/Foundation/src/VarIterator.cpp
        ${LIBRARY_DIR}/Foundation/src/VarVisitor.cpp
        ${LIBRARY_DIR}/Foundation/src/Void.cpp
        ${LIBRARY_DIR}/Foundation/src/Windows1250Encoding.cpp
        ${LIBRARY_DIR}/Foundation/src/Windows1251Encoding.cpp
        ${LIBRARY_DIR}/Foundation/src/Windows1252Encoding.cpp
        )

list(REMOVE_ITEM SRCS ${SRCS_PCRE} ${SRCS_ZLIB} ${SRCS_UTF8PROC})

add_library(_poco_foundation ${SRCS})
add_library(Poco::Foundation ALIAS _poco_foundation)

target_compile_options(_poco_foundation
        PRIVATE
        -Wno-atomic-implicit-seq-cst
        -Wno-deprecated
        -Wno-extra-semi-stmt
        -Wno-zero-as-null-pointer-constant
        -Wno-implicit-int-float-conversion
        -Wno-thread-safety-analysis
        -Wno-thread-safety-negative
        )
target_compile_options(_poco_foundation
        PRIVATE
        -Wno-sign-compare
        -Wno-unused-parameter
        )
target_compile_definitions(_poco_foundation
        PRIVATE
        POCO_UNBUNDLED
        POCO_UNBUNDLED_ZLIB
        PUBLIC
        POCO_ENABLE_CPP11
        POCO_OS_FAMILY_UNIX
        )
target_include_directories(_poco_foundation SYSTEM PUBLIC ${LIBRARY_DIR}/Foundation/include)
target_include_directories(_poco_foundation PRIVATE ${LIBRARY_DIR}/Foundation/src)
target_link_libraries(_poco_foundation PRIVATE Poco::Foundation::PCRE Poco::Foundation::ZLIB Poco::Foundation::UTF8PROC)
